﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using iTeachSoft.CoreObjects;
using iTeachSoft.Code.Managers;
using iTeachSoft.Presentation.Code.Managers;
using System.Windows;

namespace iTeachSoft.Presentation.Code.Wrappers
{
    public class SlideTreeViewItem : TreeViewItem
    {
        private Slide mCoreSlide = null;

        public SlideTreeViewItem(Slide slide)
        {
            mCoreSlide = slide;
            this.Header = "Slide " + RuntimeStorage.CurrentProject.Slides.IndexOf(slide).ToString();
            this.Style = (Style)Application.Current.FindResource("TreeViewItemShapeStyle");

            BuildContextMenu();
        }

        private void BuildContextMenu()
        {
            var menu = new ContextMenu();

            var miDelete = new MenuItem() { Header = "Delete slide" };
            miDelete.Click += new System.Windows.RoutedEventHandler(miDelete_Click);
            menu.Items.Add(miDelete);

            this.ContextMenu = menu;
        }

        void miDelete_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            ActionsManager.DeleteSlide(mCoreSlide);
        }
    }
}
